import { appendO } from '$util';
import { writable, readable, derived } from 'svelte/store';

export interface PartnerItem {
	logo: string;
	title: string;
	desc?: string;
	isRight: boolean;
}

const _partnerItems: PartnerItem[] = [
	{
		logo: 'partner-plan-1',
		title: '多样收益',
		desc: '产品销售提成+代运营增值收⼊+老客带新客，带来源源不断的收入',
		isRight: true
	},
	{
		logo: 'partner-plan-2',
		title: '销售资源',
		desc: '全年开展资源对接、行业论坛等活动，协助代理商快速推广。',
		isRight: true
	},
	{
		logo: 'partner-plan-3',
		title: '培训赋能',
		desc: '直播培训、视频教学、讲师集训等多形式，助力快速熟悉业务，提升管理能力。',
		isRight: true
	},
	{
		logo: 'partner-plan-4',
		title: '市场物料',
		desc: '总部提供产品、开单、激励等多种物料，统一品牌形象，快速占据市场。',
		isRight: true
	},
	{
		logo: 'partner-plan-5',
		title: '专属客服',
		desc: '代理商咨询专线，专属客服经理7*12小时贴心陪伴、答疑解惑。',
		isRight: true
	},
	{
		logo: 'partner-plan-6',
		title: '技术保障',
		desc: '8年技术沉淀，系统安全稳定，技术支持团队随时待命，快速解决问题。',
		isRight: true
	},
	{
		logo: 'partner-plan-7',
		title: '具备公司资质',
		isRight: false
	},
	{
		logo: 'partner-plan-8',
		title: '认同价值观',
		isRight: false
	},
	{
		logo: 'partner-plan-9',
		title: '行业经验',
		isRight: false
	},
	{
		logo: 'partner-plan-10',
		title: '客户资源',
		isRight: false
	}
];

export const partnerRights = readable(_partnerItems.filter((i) => i.isRight));
export const partnerConditions = readable(_partnerItems.filter((i) => !i.isRight));

export interface Partner {
	logo: string;
	title: string;
	tags: string[];
	star: number;
}

const _emptyPartner: Partner = {
	logo: '',
	title: '',
	tags: [], // '营销创意', '在线设计'
	star: 5
};

const _partners: Partner[] = [];

export const partners = writable(_partners);

export const showQualityPartners = derived(partners, ($partners) => {
	return appendO(
		$partners.filter((i) => i.star === 5),
		_emptyPartner,
		12
	);
});
